package com.example.easyexcel.dao;

import com.example.easyexcel.dto.AssetReportDTO;
import com.example.easyexcel.dto.AssetReportInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AssetReportInfoMapper {
    /**
     * 单条插入
     * @param entity 报表信息实体
     * @return 插入结果
     */
    int insert(AssetReportInfo entity);

    /**
     * 批量插入
     * @param list 报表信息列表
     * @return 插入结果
     */
    int insertBatch(@Param("list") List<AssetReportInfo> list);

    /**
     * 清空表数据
     */
    void truncateTable();

    /**
     * 查询需要迁移的报表信息
     */
    /**
     * 查询需要迁移的报表信息（完整字段）
     */
    @Select("SELECT report_id, asset_no, system_name, report_name, report_sc, " +
            "create_time, update_time, del_flag " +
            "FROM asset_report_info " +
            "WHERE del_flag = 0 AND asset_no IS NOT NULL")
    @Results({
            @Result(property = "reportId", column = "report_id"),
            @Result(property = "assetNo", column = "asset_no"),
            @Result(property = "systemName", column = "system_name"),
            @Result(property = "reportName", column = "report_name"),
            @Result(property = "reportSc", column = "report_sc"),
            @Result(property = "createTime", column = "create_time"),
            @Result(property = "updateTime", column = "update_time"),
            @Result(property = "delFlag", column = "del_flag")
    })
    List<AssetReportDTO> selectReportInfoForMigration();
}
